<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <script>
        class myArray extends Array {
            constructor() {
                super();
            }
        }

        const colors = new myArray();
        colors[0] = 'pink';
        console.log(colors.length);

        colors.length = 0;
        console.log(colors[0]);


        class moviesCollection extends Array {
            constructor(name, ...items) {
                super(...items);
                this.name = name;
            }
            add(movie) {
                this.push(movie);
            }
            rank(limit = 10) {
                return this.sort((a, b) => (a.score > b.score) ? -1 : 1).slice(0, limit);
            }
        }
        const movies = new moviesCollection('favorite movies',
            { name: 'the croods', score: 8.7 },
            { name: 'leon', score: 9.4 },
            { name: 'days of summer', score: 8.0 },
        )
        movies.push({ name: 'Captain America', score: 8.5 })
    </script>
</body>

</html>